package cn.lhjl.day04.bankserve;

import java.util.Date;

public abstract class User {
    private String name;
    private String sex;
    private Date birthday;
    private String idCard;
    private String phoneNum;
    private Account account;

    public void saveMoney(double money) {
        double add = money + this.account.getMoneyNum();
        this.account.setMoneyNum(add);
    }

    public double receiveMoney(double money) {
        if (money > this.account.getMoneyNum()) {
            System.out.println("余额不足，不能取款。");
            return 0;
        }
        double leftMoney = this.account.getMoneyNum() - money;
        this.account.setMoneyNum(leftMoney);
        return money;
    }

    public User() {
    }

    public User(String name, String sex, Date birthday, String idCard, String phoneNum, Account account) {
        this.name = name;
        this.sex = sex;
        this.birthday = birthday;
        this.idCard = idCard;
        this.phoneNum = phoneNum;
        this.account = account;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    public String getPhoneNum() {
        return phoneNum;
    }

    public void setPhoneNum(String phoneNum) {
        this.phoneNum = phoneNum;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", birthday=" + birthday +
                ", idCard='" + idCard + '\'' +
                ", phoneNum='" + phoneNum + '\'' +
                ", account=" + account +
                '}';
    }
}
